<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>合作关系处理</title>
    <link rel="stylesheet" href="/css/index.css" type="text/css">
    <script src="/js/vue.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/index.js"></script>
</head>

<body>
<div id="app">
    <template>
        <div class="block">
            <el-date-picker
                    v-model="value1"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择开始日期">
            </el-date-picker>
            <el-date-picker
                    v-model="value2"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择结束日期">
            </el-date-picker>
            <el-button @click="loadTime">查询</el-button>
        </div>
    </template>
    <el-button @click="loadA">查看申请请求</el-button>
    <el-button @click="loadB">处理申请请求</el-button>
    <el-table
            ref="parTable"
            :data="pars"
            style="width: 100%">
        <el-table-column
                width="55">
        </el-table-column>
        <el-table-column
                label="申请编号">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.id }}</span>
            </template>
        </el-table-column>
        <el-table-column
                label="处理状态">
            <template slot-scope="scope">
                <span style="margin-left: 10px;cursor: pointer" >{{ scope.row.tparStatus }}</span>
            </template>
        </el-table-column>
        <el-table-column
                label="申请状态">
            <template slot-scope="scope">
                <span style="margin-left: 10px"><el-tag type="success">{{ scope.row.tparStatus2 }}</el-tag></span>
            </template>
        </el-table-column>
        <el-table-column
                label="申请时间">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.tparTime }}</span>
            </template>
        </el-table-column>
        <el-table-column
                label="备注">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.tparDesc }}</span>
            </template>
        </el-table-column>
        <el-table-column
                label="申请公司">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.scompanyA.companyName }}</span>
            </template>
        </el-table-column>
        <el-table-column
                label="被申请公司">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.scompanyB.companyName }}</span>
            </template>
        </el-table-column>
        <el-table-column
                label="申请公司身份">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.tparRel }}</span>
            </template>
        </el-table-column>
        <el-table-column label="操作">
            <template slot-scope="scope">
                <el-button
                        size="mini"
                        @click="deal(scope.$index, scope.row)"
                >通过
                </el-button>
                <el-button
                        size="mini"
                        @click="nodeal(scope.$index, scope.row)"
                >拒绝
                </el-button>
            </template>
        </el-table-column>
    </el-table>
    <el-pagination
            background
            layout="prev, pager, next"
            :total="total"
            :page-size="size"
            :current-page="current"
            @current-change="loadAll">
    </el-pagination>
</div>
<script>
    new Vue({
        el:"#app",
        data(){
            return{
                pars:[],
                par:[],
                total:0,
                current:1,
                size:10,
                time1:'',
                time2:'',
                value1:'',//时间范围
                value2:'',//时间范围
            }
        },
        methods:{
            //本公司申请
            loadA(){
                let current = this.current
                let size = this.size
                axios.get("/pars/"+current+"/"+size).then(res=>{
                    this.pars = res.data.records;
                    this.total = res.data.total;
                    this.current = res.data.current;
                })
            },
            //需要处理的申请
            loadB(){
                let current = this.current
                let size = this.size
                axios.get("/par/"+current+"/"+size).then(res=>{
                    this.pars = res.data.records;
                    this.total = res.data.total;
                    this.current = res.data.current;
                })
            },
            //时间查询
            loadTime(){
                let size=this.size
                let time1 = this.value1
                let time2 = this.value2
                let current =this.current
                axios.get("/par/"+current+"/"+size+"/"+time1+"/"+time2).then(res=>{
                    this.pars = res.data.records;
                    this.total = res.data.total;
                    this.current = res.data.current;
                })
            },
            //查询所有
            loadAll(current){
                let size=this.size
                axios.get("/pars/all/"+current+"/"+size).then(res=>{
                    this.pars = res.data.records;
                    this.total = res.data.total;
                    this.current = res.data.current;
                })
            },
            //处理审核的方法
            deal(index,row){
                let par =JSON.parse(JSON.stringify(row))
                axios.post("/relation/ok",par).then(res=>{
                    this.$message(res.data)
                })
            },
            //处理审核的方法
            nodeal(index,row){
                let par =JSON.parse(JSON.stringify(row))
                axios.post("/relation/no",par).then(res=>{
                    this.$message(res.data)
                })
            }
        },
        mounted(){
           this.loadAll(1)
        }
    })
</script>
</body>
</html>